package Difficult.findMedianSortedArrays;

import java.util.Arrays;
import java.util.stream.IntStream;

public class findMedianSortedArrays1 {
    public static void main(String[] args) {
        int[] nums1 = new int[]{1,3};
        int[] nums2 = new int[]{2};
        System.out.println(findMedianSortedArrays(nums1, nums2));
    }
    public static double findMedianSortedArrays(int[] nums1, int[] nums2) {
        IntStream s1 = Arrays.stream(nums1);
        IntStream s2 = Arrays.stream(nums2);;
        int[] array = IntStream.concat(s1, s2).sorted().toArray();

        if (array.length % 2 != 0) {
            return array[array.length / 2];
        }
        return (double) (array[array.length / 2 - 1] + array[array.length / 2]) /2;
    }
}
